<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"/>
	<title>demo1</title>
	<meta name="keywords" content=""/>
	<meta name="description" content=""/>
	<meta name="viewport" content="width=device-width"/>
	<link rel="shortcut icon" href="img/touchicon.png"/>
	<link rel="stylesheet" href=""/>
	<style type="text/css">
		input{color:#aaa;}
	</style>
</head>
<body>
	<input type="text" value="用户名" id="UserName">
	<input type="text" value="密码" id="PassWord">
	<script>
		var UserName = document.getElementById('UserName');
		var PassWord = document.getElementById('PassWord');
		UserName.onclick = function () {
			if (UserName.value=='用户名') {
				UserName.value = '';
				UserName.style.color = '#333';
			}
		}
		UserName.onblur = function(){
			if (UserName.value==''){
				UserName.value = '用户名';
				UserName.style.color = '#aaa';
			}
		}
		PassWord.onclick = function () {
			if (PassWord.value=='密码') {
				PassWord.value = '';
				PassWord.style.color = '#333';
			}
		}
		PassWord.onblur = function(){
			if (PassWord.value==''){
				PassWord.value = '密码';
				PassWord.style.color = '#aaa';
			}
		}
	</script>
</body>
</html>